home *** CD-ROM | disk | FTP | other *** search
/ Programming Languages Suite / ProgramD2.iso / Borland / Borland C++ V5.02 / EDITSDI.PAK / EDITSDI.C < prev    next >
C/C++ Source or Header  |  1997-05-06  |  18KB  |  675 lines

  1. // THIS CODE AND INFORMATION IS PROVIDED "AS IS" WITHOUT WARRANTY OF
  2. // ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING BUT NOT LIMITED TO
  3. // THE IMPLIED WARRANTIES OF MERCHANTABILITY AND/OR FITNESS FOR A
  4. // PARTICULAR PURPOSE.
  5. //
  6. // Copyright (C) 1993-1995  Microsoft Corporation.  All Rights Reserved.
  7. //
  8. //  MODULE: edit.c
  9. //
  10. //  PURPOSE: Handle basic functionality of the edit control.
  11. //
  12. //  FUNCTIONS:
  13. //    GetFName          - Get the current file name.
  14. //    GetEditWindow     - Return a handle to the current edit control.
  15. //    WndProc           - Processes messages for the main window.
  16. //    MsgCommand        - Handle the WM_COMMAND messages for the main window.
  17. //    MsgDestroy        - Handle the WM_DESTROY message by calling 
  18. //                        PostQuitMessage().
  19. //    MsgSetFocus       - Sets the focus to the edit control when main window
  20. //                        gets it.
  21. //    MsgQueryEndSession- Handles the case where user attempts to quit with
  22. //                        unsaved changes.
  23. //    MsgClose          - Close the editor.
  24. //    MsgSize           - Resize the editor window when the main window has
  25. //                        been resized.
  26. //    MsgInitMenu       - Enable/Disable the paste menu command.
  27. //    CmdEdit           - Hand edit control notifications.
  28. //    CmdClip           - Handle clipboard commands.
  29. //    CmdExit           - Handles the file exit command by calling destory
  30. //                        window on the main window.
  31. //    InitEdit          - Do editor specific initialization.
  32. //    SetEditText       - Set the text of the edit control hwnd.
  33. //    LockEditText      - Return a handle to the text associated with the
  34. //                        edit control.
  35. //    UnlockEditText    - Unlock the handle to the text associated with the
  36. //                        edit control.
  37. //
  38. //  COMMENTS:
  39. //
  40.  
  41.  
  42. #include <windows.h>            // required for all Windows applications
  43. #ifdef WIN16
  44. #include "win16ext.h"           // required only for win16 applications
  45. #endif
  46. #include "globals.h"            // prototypes specific to this application
  47. #include "resource.h"
  48.                  
  49. //
  50. //  FUNCTION: GetFName(VOID)
  51. //
  52. //  PURPOSE: Get the current file name.
  53. //
  54. //  PARAMETERS:
  55. //    NONE
  56. //
  57. //  RETURN VALUE:
  58. //    The full path name of the current file.
  59. //
  60. //  COMMENTS:
  61. //
  62. //
  63.  
  64. char *GetFName(VOID)
  65. {
  66.      return szFName;
  67. }
  68.  
  69. //
  70. //  FUNCTION: GetEditWindow(VOID)
  71. //
  72. //  PURPOSE: Return a handle to the current edit control.
  73. //
  74. //  PARAMETERS:
  75. //    NONE
  76. //
  77. //  RETURN VALUE:
  78. //    A handle to the current edit control.
  79. //
  80. //  COMMENTS:
  81. //    This functionality is implemented as an inline function rather than
  82. //    exporting hwndEdit.  Making it an inline function obviates the
  83. //    efficiency arguments for using an exported variable.
  84. //
  85.  
  86. HWND GetEditWindow(VOID)
  87. {
  88.      return hwndEdit;
  89. }
  90.  
  91. // Main window message table definition.
  92. static MSD rgmsd[] =
  93. {
  94.     {0,                 MsgFindReplace},
  95.     {WM_COMMAND,        MsgCommand},
  96.     {WM_DESTROY,        MsgDestroy},
  97.     {WM_INITMENU,       MsgInitMenu},
  98.     {WM_SETFOCUS,       MsgSetFocus},
  99.     {WM_SIZE,           MsgSize},
  100.     {WM_QUERYENDSESSION,MsgQueryEndSession},
  101.     {WM_CLOSE,          MsgClose}
  102. };
  103.  
  104. MSDI msdiMain =
  105. {
  106.     sizeof(rgmsd) / sizeof(MSD),
  107.     rgmsd,
  108.     edwpWindow
  109. };
  110.  
  111. // Main window command table definition.
  112. static CMD rgcmd[] =
  113. {
  114.     {IDM_FILENEW,    CmdFileNew},
  115.     {IDM_FILEOPEN,   CmdFileOpen},
  116.     {IDM_FILESAVE,   CmdFileSave},
  117.     {IDM_FILESAVEAS, CmdFileSaveAs},
  118.     {IDM_FILEPRINT,  CmdPrint},
  119.     {IDM_FILEPRINTSU,CmdPrintSU},
  120.     {IDC_EDIT,       CmdEdit},
  121.     {IDM_EXIT,       CmdExit},
  122.     {IDM_ABOUT,      CmdAbout},
  123.     {IDM_CUT,        CmdClip},
  124.     {IDM_COPY,       CmdClip},
  125.     {IDM_CLEAR,      CmdClip},
  126.     {IDM_PASTE,      CmdClip},
  127.     {IDM_UNDO,       CmdClip},
  128.     {IDM_FIND,       CmdFindReplace},
  129.     {IDM_REPLACE,    CmdFindReplace},
  130.     {IDM_FINDNEXT,   CmdFindNext},
  131.     {IDM_FINDPREV,   CmdFindNext}
  132. };
  133.  
  134. CMDI cmdiMain =
  135. {
  136.     sizeof(rgcmd) / sizeof(CMD),
  137.     rgcmd,
  138.     edwpWindow
  139. };
  140.  
  141. //Module specific "globals"
  142.  
  143. HWND hwndEdit;                               // Edit control handle
  144. HCURSOR hcursHourGlass;
  145.  
  146. #ifndef WIN16
  147. static HANDLE hszEditBuffer = NULL;
  148. #endif
  149.  
  150. //
  151. //  FUNCTION: WndProc(HWND, UINT, WPARAM, LPARAM)
  152. //
  153. //  PURPOSE:  Processes messages for the main window.
  154. //
  155. //  PARAMETERS:
  156. //    hwnd     - window handle
  157. //    uMessage - message number
  158. //    wparam   - additional information (dependant on message number)
  159. //    lparam   - additional information (dependant on message number)
  160. //
  161. //  RETURN VALUE:
  162. //    The return value depends on the message number.  If the message
  163. //    is implemented in the message dispatch table, the return value is
  164. //    the value returned by the message handling function.  Otherwise,
  165. //    the return value is the value returned by the default window procedure.
  166. //
  167. //  COMMENTS:
  168. //    Call the DispMessage() function with the main window's message dispatch
  169. //    information (msdiMain) and the message specific information.
  170. //
  171.  
  172. LRESULT CALLBACK WndProc
  173.     (HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  174. {
  175.     return DispMessage(&msdiMain, hwnd, uMessage, wparam, lparam);
  176. }
  177.  
  178.  
  179. //
  180. //  FUNCTION: MsgCommand(HWND, UINT, WPARAM, LPARAM)
  181. //
  182. //  PURPOSE: Handle the WM_COMMAND messages for the main window.
  183. //
  184. //  PARAMETERS:
  185. //    hwnd     - window handle
  186. //    uMessage - WM_COMMAND (Unused)
  187. //    GET_WM_COMMAND_ID(wparam,lparam)   - Command identifier
  188. //    GET_WM_COMMAND_HWND(wparam,lparam) - Control handle
  189. //
  190. //  RETURN VALUE:
  191. //    The return value depends on the message number.  If the message
  192. //    is implemented in the message dispatch table, the return value is
  193. //    the value returned by the message handling function.  Otherwise,
  194. //    the return value is the value returned by the default window procedure.
  195. //
  196. //  COMMENTS:
  197. //    Call the DispCommand() function with the main window's command dispatch
  198. //    information (cmdiMain) and the command specific information.
  199. //
  200.  
  201. #pragma argsused
  202. LRESULT MsgCommand(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  203. {
  204.     return DispCommand(&cmdiMain, hwnd, wparam, lparam);
  205. }
  206.  
  207.  
  208.  
  209. //
  210. //  FUNCTION: MsgSetFocus(HWND, UINT, WPARAM, LPARAM)
  211. //
  212. //  PURPOSE: Sets the focus to the edit control when main window gets it.
  213. //
  214. //  PARAMETERS:
  215. //    hwnd - The window handing the message.
  216. //    uMessage - The message number. (unused).
  217. //    wparam - Message specific data (unused).
  218. //    lparam - Message specific data (unused).
  219. //
  220. //  RETURN VALUE:
  221. //    Always returns 0 - message handled.
  222. //
  223. //  COMMENTS:
  224. //
  225. //
  226.  
  227. #pragma argsused
  228. LRESULT MsgSetFocus(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  229. {
  230.      SetFocus (GetEditWindow());
  231.      return 0;
  232. }
  233.  
  234.  
  235. //
  236. //  FUNCTION: MsgQueryEndSession(HWND, UINT, WPARAM, LPARAM)
  237. //
  238. //  PURPOSE: Handles the case where user attempts to quit with unsaved changes.
  239. //
  240. //  PARAMETERS:
  241. //    hwnd - The window handing the message.
  242. //    uMessage - The message number. (unused).
  243. //    wparam - Message specific data (unused).
  244. //    lparam - Message specific data (unused).
  245. //
  246. //  RETURN VALUE:
  247. //    TRUE - Quiting is now safe.
  248. //    FALSE - Don't quit.
  249. //
  250. //  COMMENTS:
  251. //    Let the function QuerySaveFile handle the real work.
  252. //
  253.  
  254. #pragma argsused
  255. LRESULT MsgQueryEndSession(HWND hwnd,
  256.                                     UINT uMessage,
  257.                                     WPARAM wparam,
  258.                                     LPARAM lparam)
  259. {
  260.     return QuerySaveFile(hwnd);
  261. }
  262.  
  263.  
  264. //
  265. //  FUNCTION: MsgClose(HWND, UINT, WPARAM, LPARAM)
  266. //
  267. //  PURPOSE: Close the editor.
  268. //
  269. //  PARAMETERS:
  270. //    hwnd     - The window handing the message.
  271. //    uMessage - The message number. (unused).
  272. //    wparam   - Message specific data (unused).
  273. //    lparam   - Message specific data (unused).
  274. //
  275. //  RETURN VALUE:
  276. //    Always returns 0 - message handled.
  277. //
  278. //  COMMENTS:
  279. //
  280. //
  281.  
  282. #pragma argsused
  283. LRESULT MsgClose(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  284. {
  285.      if (QuerySaveFile(hwnd))
  286.         DestroyWindow(hwnd);
  287.     return 0;
  288. }
  289.  
  290.  
  291. //
  292. //  FUNCTION: MsgSize(HWND, UINT, WPARAM, LPARAM)
  293. //
  294. //  PURPOSE: Resize the editor window when the main window has been resized.
  295. //
  296. //  PARAMETERS:
  297. //    hwnd - The window handing the message.
  298. //    uMessage - The message number. (unused).
  299. //    wparam - Message specific data (unused).
  300. //    lparam - Message specific data (unused).
  301. //
  302. //  RETURN VALUE:
  303. //    Always returns 0 - message handled.
  304. //
  305. //  COMMENTS:
  306. //
  307. //
  308.  
  309. #pragma argsused
  310. LRESULT MsgSize(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  311. {
  312.     MoveWindow(GetEditWindow(), 0, 0, LOWORD(lparam), HIWORD(lparam), TRUE);
  313.     return 0;
  314. }
  315.  
  316.  
  317. //
  318. //  FUNCTION: MsgInitMenu(HWND, UINT, WPARAM, LPARAM)
  319. //
  320. //  PURPOSE: Enable/Disable the paste menu command.
  321. //
  322. //  PARAMETERS:
  323. //    hwnd      - Window handle
  324. //    uMessage  - WM_INITMENU (Unused)
  325. //    wparam    - HMENU - The menu about to be activated
  326. //    lparam    - Extra data     (Unused)
  327. //
  328. //  RETURN VALUE:
  329. //    0 - The message was handled.
  330. //    1 - The message was not handled - wrong menu.
  331. //
  332. //  COMMENTS:
  333. //
  334. //
  335.  
  336. #pragma argsused
  337. LRESULT MsgInitMenu(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  338. {
  339.      if (GetMenu(hwnd) == (HMENU)wparam)
  340.     {
  341.         UINT mf = MF_GRAYED;
  342.         UINT ichStart;
  343.         UINT ichEnd;
  344.  
  345.         // Enable/Disable Paste menu item
  346.         if (OpenClipboard(hwnd))
  347.         {
  348.             if (IsClipboardFormatAvailable(CF_TEXT) ||
  349.                 IsClipboardFormatAvailable(CF_OEMTEXT))
  350.             {
  351.                 mf = MF_ENABLED;
  352.                 }
  353.         }
  354.         CloseClipboard();
  355.  
  356.         EnableMenuItem((HMENU)wparam, IDM_PASTE, mf);
  357.  
  358.         // Enable/Disable Undu menu item
  359.         mf = SendMessage(GetEditWindow(), EM_CANUNDO, 0, 0L) ?
  360.             MF_ENABLED : MF_GRAYED;
  361.         EnableMenuItem((HMENU)wparam, IDM_UNDO, mf);
  362.  
  363.         // Enable/Disable Cut/Copy/Delete menu items
  364.         GETSEL(ichStart,ichEnd);
  365.           mf = (ichEnd != ichStart) ? MF_ENABLED : MF_GRAYED;
  366.         EnableMenuItem((HMENU)wparam, IDM_CUT, mf);
  367.         EnableMenuItem((HMENU)wparam, IDM_COPY, mf);
  368.         EnableMenuItem((HMENU)wparam, IDM_CLEAR, mf);
  369.  
  370.         // Enable/Disable Save menu item
  371.         mf = SendMessage(GetEditWindow(), EM_GETMODIFY, 0, 0L) ? MF_ENABLED : MF_GRAYED;
  372.         EnableMenuItem((HMENU)wparam, IDM_FILESAVE, mf);
  373.  
  374.         // Enable/Disable FindNext/FindPrev menu intes
  375.         mf = CanFind() ? MF_ENABLED : MF_GRAYED;
  376.         EnableMenuItem((HMENU)wparam, IDM_FINDNEXT, mf);
  377.         EnableMenuItem((HMENU)wparam, IDM_FINDPREV, mf);
  378.  
  379.         return 0;
  380.     }
  381.     else
  382.         return 1;
  383. }
  384.  
  385.  
  386. //
  387. //  FUNCTION: MsgDestroy(HWND, UINT, WPARAM, LPARAM)
  388. //
  389. //  PURPOSE: Calls PostQuitMessage().
  390. //
  391. //  PARAMETERS:
  392. //
  393. //    hwnd      - Window handle  (Unused)
  394. //    uMessage  - Message number (Unused)
  395. //    wparam    - Extra data     (Unused)
  396. //    lparam    - Extra data     (Unused)
  397. //
  398. //  RETURN VALUE:
  399. //
  400. //    Always returns 0 - Message handled
  401. //
  402. //  COMMENTS:
  403. //
  404. //
  405.  
  406. #pragma argsused
  407. LRESULT MsgDestroy(HWND hwnd, UINT uMessage, WPARAM wparam, LPARAM lparam)
  408. {
  409.     PostQuitMessage(0);
  410.     return 0;
  411. }
  412.  
  413.  
  414. //
  415. //  FUNCTION: CmdEdit(HWND, WORD, WORD, HWND)
  416. //
  417. //  PURPOSE: Hand edit control notifications.
  418. //
  419. //  PARAMETERS:
  420. //    hwnd     - The window.
  421. //    wCommand - IDC_EXIT (unused)
  422. //    wNotify  - EN_*
  423. //    hwndCtrl - NULL (unused)
  424. //
  425. //  RETURN VALUE:
  426. //    Always returns 0 - command handled.
  427. //
  428. //  COMMENTS:
  429. //    Handle the edit control's out of space error by putting up an
  430. //    "Out of Memory" warning dialog.
  431. //
  432.  
  433. #pragma argsused
  434. LRESULT CmdEdit(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
  435. {
  436.      switch (wNotify)
  437.      {
  438.           case EN_ERRSPACE:
  439.                 MessageBox(hwnd,
  440.                        "Out of memory.", 
  441.                        SZDESCRIPTION, 
  442.                        MB_ICONHAND | MB_OK);
  443.             break;
  444.     }
  445.     return 0;
  446. }
  447.  
  448.  
  449. //
  450. //  FUNCTION: CmdClip(HWND, WORD, WORD, HWND)
  451. //
  452. //  PURPOSE: Handle clipboard commands.
  453. //
  454. //  PARAMETERS:
  455. //    hwnd     - The window.
  456. //    wCommand - IDM_CUT, IDM_COPY, IDM_CLEAR IDM_PASTE, IDM_UNDO
  457. //    wNotify  - Notification number (unused)
  458. //    hwndCtrl - NULL (unused)
  459. //
  460. //  RETURN VALUE:
  461. //    Always returns 0 - command handled.
  462. //
  463. //  COMMENTS:
  464. //    Translate the commands into messages and send them to the edit control.
  465. //
  466.  
  467. #pragma argsused
  468. LRESULT CmdClip(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
  469. {
  470.      WORD wMessage = 0;
  471.  
  472.      switch (wCommand)
  473.      {
  474.           case IDM_CUT:   wMessage = WM_CUT;   break;
  475.           case IDM_COPY:  wMessage = WM_COPY;  break;
  476.         case IDM_PASTE: wMessage = WM_PASTE; break;
  477.         case IDM_CLEAR: wMessage = WM_CLEAR; break;
  478.         case IDM_UNDO:  wMessage = EM_UNDO;  break;
  479.     }
  480.  
  481.     SendMessage(GetEditWindow(), wMessage, 0, 0L);
  482.     return 0;
  483. }
  484.  
  485.  
  486. //
  487. //  FUNCTION: CmdExit(HWND, WORD, WORD, HWND)
  488. //
  489. //  PURPOSE: Exit the application.
  490. //
  491. //  PARAMETERS:
  492. //    hwnd     - The window.
  493. //    wCommand - IDM_EXIT (unused)
  494. //    wNotify  - Notification number (unused)
  495. //    hwndCtrl - NULL (unused)
  496. //
  497. //  RETURN VALUE:
  498. //    Always returns 0 - command handled.
  499. //
  500. //  COMMENTS:
  501. //
  502. //
  503.  
  504. #pragma argsused
  505. LRESULT CmdExit(HWND hwnd, WORD wCommand, WORD wNotify, HWND hwndCtrl)
  506. {
  507.     if (QuerySaveFile(hwnd))
  508.        DestroyWindow(hwnd);
  509.     return 0;
  510. }
  511.  
  512.  
  513. //
  514. //  FUNCTION: InitEdit(HWND)
  515. //
  516. //  PURPOSE: Do editor specific initialization.
  517. //
  518. //  PARAMETERS:
  519. //    hwnd - The main application window.
  520. //
  521. //  RETURN VALUE:
  522. //    TRUE - If initialization was successful.
  523. //    FALSE - If initialization failed.
  524. //
  525. //  COMMENTS:
  526. //    Create the multi-line edit control as a child of the main application
  527. //    window.  Also load the hour-glass cursor for display when saving
  528. //    and printing.
  529.  
  530. BOOL InitEdit(HWND hwnd)
  531. {
  532.     RECT rc;
  533.  
  534.     GetClientRect(hwnd, &rc);
  535.  
  536.     hwndEdit = CreateWindow("Edit",
  537.                             NULL,
  538.                             WS_CHILD   | WS_VISIBLE | ES_MULTILINE   |
  539.                             WS_VSCROLL | WS_HSCROLL | ES_AUTOHSCROLL |
  540.                             ES_AUTOVSCROLL | ES_NOHIDESEL,
  541.                             0, 0,
  542.                             (rc.right-rc.left), (rc.bottom-rc.top),
  543.                             hwnd,
  544.                             (HMENU)IDC_EDIT,           // Child control i.d.
  545.                             hInst,
  546.                             NULL);
  547.  
  548.     if (!hwndEdit)
  549.     {
  550.         DestroyWindow(hwnd);
  551.         return FALSE;
  552.     }
  553.     else
  554.     {
  555.         hcursHourGlass = LoadCursor(NULL, IDC_WAIT);
  556.         return TRUE;
  557.     }
  558. }
  559.  
  560.  
  561. //
  562. //  FUNCTION: SetEditText(HWND, hsz)
  563. //
  564. //  PURPOSE: Set the text of the edit control hwnd.
  565. //
  566. //  PARAMETERS:
  567. //    hwnd - The edit control to set.
  568. //    hsz  - A local handle to the text to set.
  569. //
  570. //  RETURN VALUE:
  571. //    NONE
  572. //
  573. //  COMMENTS:
  574. //    Some implementation of the WIN32 api do not correctly handle
  575. //    EM_SETHANDLE and EM_GETHANDLE.  SetEditText, LockEditText, and
  576. //    UnlockEditText encapsulate the workaround for this limitation.
  577. //
  578.  
  579. #pragma argsused
  580. VOID SetEditText(HWND hwnd, HANDLE hsz)
  581. {
  582. #ifdef WIN16
  583.     HANDLE hszOld;
  584.  
  585.     hszOld = (HANDLE)SendMessage(hwnd, EM_GETHANDLE, 0, 0L);
  586.     LocalFree(hszOld);
  587.     SendMessage(hwnd, EM_SETHANDLE, (WPARAM) hsz, 0L);
  588. #else
  589.     //
  590.     // For Win32s, use WM_SETTEXT.
  591.     //
  592.     // Win32s has 32-bit local memory handles which it cannot pass to
  593.      // Win3.1.  This means that the EM_SETHANDLE and EM_GETHANDLE messages
  594.     // are not supported.  A private 16-bit heap (unknown to the app)
  595.     // provides space for the multiline edit control.
  596.     //
  597.  
  598.     char *sz = LocalLock(hsz);
  599.     SendMessage(GetEditWindow(), WM_SETTEXT, 0, (LPARAM)(LPSTR)sz);
  600.     LocalUnlock(hsz);
  601.     LocalFree(hsz);
  602. #endif
  603. }
  604.  
  605.  
  606. //
  607. //  FUNCTION: LockEditText(HWND)
  608. //
  609. //  PURPOSE: Return a handle to the text associated with the edit control.
  610. //
  611. //  PARAMETERS:
  612. //    hwnd - The edit control whose text is to be locked.
  613. //
  614. //  RETURN VALUE:
  615. //    A local buffer containing the text associated with the editor control.
  616. //
  617. //  COMMENTS:
  618. //
  619. //
  620.  
  621. char *LockEditText(HWND hwnd)
  622. {
  623. #ifdef WIN16
  624.     HANDLE hsz = (HANDLE)SendMessage(hwnd, EM_GETHANDLE, 0, 0L);
  625.     return LocalLock(hsz);
  626. #else
  627.      // For Win32s, allocate hText and read edit control text into it.
  628.      // Lock hText and fall through to existing code.
  629.  
  630.     INT cbText;
  631.     char *sz;
  632.  
  633.     cbText = SendMessage(hwnd, WM_GETTEXTLENGTH, 0, 0L) + 1;
  634.     hszEditBuffer = LocalAlloc(LMEM_MOVEABLE | LMEM_ZEROINIT, cbText);
  635.     if (hszEditBuffer == NULL) return NULL;
  636.     sz = LocalLock(hszEditBuffer);
  637.     if (sz == NULL)
  638.     {
  639.         LocalFree(hszEditBuffer);
  640.         hszEditBuffer = NULL;
  641.         return NULL;
  642.     }
  643.     SendMessage(hwnd, WM_GETTEXT, cbText, (LPARAM)(LPSTR)sz);
  644.     return sz;
  645. #endif
  646. }
  647.  
  648.  
  649. //
  650. //  FUNCTION: UnlockEditText(HWND)
  651. //
  652. //  PURPOSE: Return a handle to the text associated with the edit control.
  653. //
  654. //  PARAMETERS:
  655. //    hwnd - The edit control whose text is to be unlocked.
  656. //
  657. //  RETURN VALUE:
  658. //    NONE
  659. //
  660. //  COMMENTS:
  661. //
  662. //
  663.  
  664. VOID UnlockEditText(HWND hwnd)
  665. {
  666. #ifdef WIN16
  667.     HANDLE hsz;
  668.     hsz = (HANDLE)SendMessage(hwnd, EM_GETHANDLE, 0, 0L);
  669.     LocalUnlock(hsz);
  670. #else
  671.     SetEditText(hwnd, hszEditBuffer);
  672.     hszEditBuffer = NULL;
  673. #endif
  674. }
  675.